package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GRtuInfo;
import com.gzck.gzck_verson2.service.IGRtuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 采集仪信息 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-rtu-info")
public class GRtuInfoController {

    @Autowired
    private IGRtuInfoService rtuInfoService;

    // 添加RTU信息
    @PostMapping("/add")
    public boolean addRtuInfo(@RequestBody GRtuInfo rtuInfo) {
        return rtuInfoService.save(rtuInfo);
    }

    // 删除RTU信息
    @DeleteMapping("/delete/{id}")
    public boolean deleteRtuInfo(@PathVariable Long id) {
        return rtuInfoService.removeById(id);
    }

    // 更新RTU信息
    @PutMapping("/update")
    public boolean updateRtuInfo(@RequestBody GRtuInfo rtuInfo) {
        return rtuInfoService.updateById(rtuInfo);
    }

    // 查询单个RTU信息
    @GetMapping("/{id}")
    public GRtuInfo getRtuInfo(@PathVariable Long id) {
        return rtuInfoService.getById(id);
    }

    // 查询所有RTU信息
    @GetMapping("/all")
    public List<GRtuInfo> getAllRtuInfos() {
        return rtuInfoService.list();
    }
}
